package com.doone.telmarket.infrastructure.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Service;

import com.doone.telmarket.domain.GuangGao;
import com.doone.telmarket.infrastructure.dao.GuangGaoDao;
import com.ibatis.sqlmap.client.SqlMapClient;

@Service("guangGaoDao")
public class GuangGaoDaoImpl extends SqlMapClientDaoSupport implements GuangGaoDao {

	@SuppressWarnings("unchecked")
	public List<GuangGao> selectAllGuangGao() {
		List<GuangGao> li = getSqlMapClientTemplate().queryForList("Guanggao.selectAllGuangGao");
		
		System.out.println(li.size());
		return li;
	}

	public void updateGuangGao(GuangGao g) {
		 getSqlMapClientTemplate().update("Guanggao.updateGangGao", g);
	}
	
	@Autowired
	public void setSqlMapClientBase(SqlMapClient sqlMapClient) {
		super.setSqlMapClient(sqlMapClient);
	}

	public void deleteGuangGao(int id) {
		getSqlMapClientTemplate().delete("Guanggao.deleteGuangGao",id);
		
	}

	public void insertGuangGao(GuangGao g) {
		getSqlMapClientTemplate().insert("Guanggao.insertGuangGao",g);
		
	}

	public GuangGao getByKey(int id) {
		// TODO Auto-generated method stub
		return (GuangGao)getSqlMapClientTemplate().queryForObject("Guanggao.selectByKey",id);
	}

}
